﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using EmaMetadata;

namespace EmaEditor
{
    public partial class frmProperties : Form
    {
        protected EmaBatch _batch;

        public frmProperties(EmaBatch batch)
        {
            InitializeComponent();

            // Load values
            _batch = batch;
            txtLastUpdated.Text = _batch.LastUpdateDate.ToString();
            txtDefaultDistance.Text = _batch.DefaultDistanceUOM;
            txtDefaultMass.Text = _batch.DefaultMassUOM;
            txtCreatorDomain.Text = _batch.MetadataCreatorFQDN;
            txtCreatorGLN.Text = _batch.MetadataCreatorGLN;
            txtCreatorName.Text = _batch.MetadataCreatorName;
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            _batch.DefaultDistanceUOM = txtDefaultDistance.Text;
            _batch.DefaultMassUOM = txtDefaultMass.Text;
            _batch.MetadataCreatorFQDN = txtCreatorDomain.Text;
            _batch.MetadataCreatorGLN = txtCreatorGLN.Text;
            _batch.MetadataCreatorName = txtCreatorName.Text;

            // Close the form and indicate that we're saving data
            DialogResult = System.Windows.Forms.DialogResult.OK;
            Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = System.Windows.Forms.DialogResult.Cancel;
            Close();
        }
    }
}
